<?php

if (isset($_COOKIE['nav_name']) && $_COOKIE['nav_name'] == 'crm') {
    define('G_DB', 'crm');
}
require ('core/shop.php');

$params_check = isset($_REQUEST ['dict']) && isset($_REQUEST ['action']);
if (!$params_check)
	die('缺少必要的请求参数');
	
$dict = $_REQUEST ['dict'];
$requestAction = $_REQUEST ['action'];
if ('processor.php' == $requestAction)
    die ();


// check authorized access
if (!('login' == $requestAction || 'wmslogin' == $requestAction)) {
    if (!$G_PGLOB->isUserLogon) {
        header('location:/quanliadmin/login.php');
        die ();
    }
    $access_url = sprintf ( 'quanliadmin/app/%s/%s.pscript', $dict, $requestAction);
    if (isset ( $_REQUEST ['operFlg'] )){
    	$access_url .= '?operFlg=' . $_REQUEST ['operFlg'];
    }

}

/**
 * 记录选择的管理功能
 */
$nav_name = $G_PGLOB->get_cookie_info('nav_name');
if (!$nav_name) {
    $nav_name = 'b2c';
    $G_PGLOB->set_cookie_info('nav_name', $nav_name, 8640000);
}
$G_PGLOB->smarty->assign('nav_name', $nav_name);

/**
 * addded by zhoulaiyin 在页面上显示当前登录用户名
 */
$userName = $G_PGLOB->currentUserName;
$G_PGLOB->smarty->assign('userName', $userName);

/**
 * 全局数组
 */
$G_PGLOB->smarty->assign('global_array', $GLOBALS);

//call action
$action_className = 'pa_' . $requestAction;
$action_fileName = sprintf ( 'quanliadmin/app/%s/action/%s.php', $dict, $action_className );
require ($action_fileName);
$pa = new $action_className ();
$pa->execute ();